package com.hj.controller;

import java.lang.ProcessBuilder.Redirect;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hj.pojo.User;

@Controller
public class LoginController {
	
	@Autowired
	HttpServletRequest request;

	@GetMapping("/login.html")
	public String login() {
		
		return "login";
	}
	
	@PostMapping("/login")
	public String login(String uname, String pw) {
		
		if (uname.equals("admin") && pw.equals("123")) {
			
			return "redirect:admin/index";
		}
		
		request.setAttribute("err", "用户名密码错误");
		return "login.html";
	}
	
}
